package com.telit.common.config;

import org.apache.commons.lang3.StringUtils;
import org.springframework.context.annotation.Condition;
import org.springframework.context.annotation.ConditionContext;
import org.springframework.core.type.AnnotatedTypeMetadata;

/**
 * @Auther amy
 * @Describe
 * 控制MinioClient Bean的加载，若是项目配置文件中添加了相应的minio配置,就加载
 */
public class MinioCondition implements Condition {

    @Override
    public boolean matches(ConditionContext conditionContext, AnnotatedTypeMetadata annotatedTypeMetadata) {
        // 获取配置文件中minio的url
        String url = conditionContext.getEnvironment().getProperty("forest.minio.url");
        if(StringUtils.isBlank(url)){
            return false;
        }
        return true;
    }
}
